|
1
|
|
|
const RequestHeaders = { |
|
2
|
|
|
locale: 'x-locale', |
|
3
|
|
|
currency: 'x-currency', |
|
4
|
|
|
deviceType: 'x-device-type', |
|
5
|
|
|
osVersion: 'x-os-version', |
|
6
|
|
|
appVersion: 'x-app-version', |
|
7
|
|
|
accessToken: 'x-access-token', |
|
8
|
|
|
}; |
|
9
|
|
|
|
|
10
|
|
|
const CurlContentTypes = { |
|
11
|
|
|
JSON: 'Application/json', |
|
12
|
|
|
MultiPartFormData: 'Multipart/form-data', |
|
13
|
|
|
}; |
|
14
|
|
|
|
|
15
|
|
|
//in case of successful create, read, update, delete & any successful operation |
|
16
|
|
|
const SUCCESS = 'success'; |
|
17
|
|
|
|
|
18
|
|
|
//in case of operational or process failure |
|
19
|
|
|
const BAD_REQUEST = 'bad_request'; |
|
20
|
|
|
|
|
21
|
|
|
//in case of authentication failure, trying to access any protected route with expired or no API token |
|
22
|
|
|
const UNAUTHORISED = 'unauthorised'; |
|
23
|
|
|
|
|
24
|
|
|
//in case of validation failure |
|
25
|
|
|
const INPROCESSABLE = 'inprocessable'; |
|
26
|
|
|
|
|
27
|
|
|
//in case of validation failure |
|
28
|
|
|
const VALIDATION_ERROR = 'validationError'; |
|
29
|
|
|
|
|
30
|
|
|
const Codes = { |
|
31
|
|
|
success: 200, |
|
32
|
|
|
bad_request: 400, |
|
33
|
|
|
unauthorised: 401, |
|
34
|
|
|
validationError: 422, |
|
35
|
|
|
inprocessable: 422, |
|
36
|
|
|
}; |
|
37
|
|
|
|
|
38
|
|
|
function getApiPossibleCodes() { |
|
39
|
|
|
return array_values(Codes); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
module.exports = { |
|
43
|
|
|
RequestHeaders: RequestHeaders, |
|
44
|
|
|
CurlContentTypes: CurlContentTypes, |
|
45
|
|
|
SUCCESS: SUCCESS, |
|
46
|
|
|
BAD_REQUEST: BAD_REQUEST, |
|
47
|
|
|
UNAUTHORISED: UNAUTHORISED, |
|
48
|
|
|
INPROCESSABLE: INPROCESSABLE, |
|
49
|
|
|
VALIDATION_ERROR: VALIDATION_ERROR, |
|
50
|
|
|
Codes: Codes, |
|
51
|
|
|
getApiPossibleCodes: getApiPossibleCodes, |
|
52
|
|
|
}; |
|
53
|
|
|
|